package com.lnsf.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.lnsf.dao.impl.SupplierDaoImpl;
import com.lnsf.model.Supplier;
import com.lnsf.model.Users;
import com.lnsf.service.ISupplierService;

public class SupplierServiceImpl implements ISupplierService {

	SupplierDaoImpl supplierdao = new SupplierDaoImpl();

	@Override
	public List<Supplier> select() {
		return supplierdao.select();
	}

	@Override
	public int insert(Supplier supplier) {
		return supplierdao.insert(supplier);
	}

	@Override
	public int update(Supplier supplier) {
		return supplierdao.update(supplier);
	}

	@Override
	public int delete(Supplier supplier) {
		return supplierdao.delete(supplier);
	}

	@Override
	public List<Supplier> selectByUid(Users users) {
		List<Supplier> list = select();
		List<Supplier> result = new ArrayList<Supplier>();
		for (int i = 0; i < list.size(); i++) {
			if (list.get(i).getuId() == users.getuId())
				result.add(list.get(i));
		}
		return result;
	}

	@Override
	public Supplier selectBySuId(int id) {
		List<Supplier> list = select();
		for (int i = 0; i < list.size(); i ++)
		{
			if (list.get(i).getSuId()==id)
			{
				return list.get(i);
			}
		}
		return null;
	}

}
